<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<p>
    整数1：<input type="text" id="num1">
</p>
<p>
    整数2：<input type="text" id="num2">
</p>
<p>
    <button onclick="b(1)">相加</button>
    <button onclick="b(2)">相减</button>
    <button onclick="b(3)">相乘</button>
    <button onclick="b(4)">相除</button>
</p>
<p>
    结果：<input type="text" id="jg">
</p>

<script>
    function b(n) {
        var text1 = document.querySelector("#num1").value;
        var text2 = document.querySelector("#num2").value;
        text1 = Number(text1);
        text2 = Number(text2);
        if (n == 1){
            document.querySelector("#jg").value = text1 + text2;
        }
        if (n == 2){
            document.querySelector("#jg").value = text1 - text2;
        }
        if (n == 3){
            document.querySelector("#jg").value = text1 * text2;
        }
        if (n == 4){
            document.querySelector("#jg").value = text1 / text2;
        }

    }



</script>

</body>
</html>